﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Linq.Expressions;
using Rocket.Core;

namespace Rocket.Windows.Framework
{
    public class RocketBaseData : UserControl
    {
        public virtual void RocketRefresh()
        {
            foreach (Control c in this.Controls)
                if ((c.GetType() == typeof(ComboBox)) ||
                    ((c.GetType() == typeof(TextBox))))
                    c.Text = "";
                else if (c.GetType() == typeof(CheckBox))
                    ((CheckBox)c).Checked = false;
        }

        private int _id;
        public int ID { get { return _id; } set { _id = value; } }
        private BindingSource _rocketBindingSource;
        public BindingSource RocketBindingSource
        {
            get { return _rocketBindingSource; }
            set
            {
                _rocketBindingSource = value;
                if ((value != null) && (OnRocketBindingSourceSetted != null))
                    OnRocketBindingSourceSetted();
            }
        }

        public virtual void SetRocketBindingSource(ref BindingSource bindingSource) { }
        public event RocketBindingSourceSetted OnRocketBindingSourceSetted;
        public event EventHandler OnRocketTaskCompleted;
        public virtual void RocketBindingSourceChanged(object sender, EventArgs e) { }
    }
}
